<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <tm-header></tm-header>
      <tm-body></tm-body>
    </div>

    <script src="../Vue.js"></script>
    <script>
      // 局部创建组件

      // 取名只能用大驼峰，使用只能使用连字符
      const TmHeader = {
        template: `
          <header>天猫头部</header>
        `,
      };

      const TmBodyButton = {
        template: `
          <button>btn</button>
        `,
      };

      const TmBody = {
        template: `
          <header>天猫内容 - <tm-body-button></tm-body-button></header>
        `,
        components: {
          TmBodyButton,
        },
      };

      new Vue({
        el: "#app",
        data: {},
        // 组件注册
        components: {
          TmHeader,
          TmBody,
        },
      });
    </script>
  </body>
</html>
